﻿using System;
using System.Text.RegularExpressions;
using System.Web;

/// <summary>
/// Summary description for Validation
/// </summary>
namespace si.caha.Helper
{
    public class Validator
    {
        public static bool IsEmailValid(string emailAddress)
        {
            string patternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+"
                  + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
                  + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
                  + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
                  + @"[a-zA-Z]{2,}))$";

            Regex reStrict = new Regex(patternStrict);
            bool isStrictMatch = reStrict.IsMatch(emailAddress);
            return reStrict.IsMatch(emailAddress);
        }

        public static bool isCookieFilled(HttpCookieCollection cookies)
        {
            return cookies["cart"] != null && cookies["cart"]["items"] != null && cookies["cart"]["items"].Length > 0;
        }
    }
}